<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: aqua;
        }
    </style>
</head>

<body>
    <div></div>
    <div></div>
    <div></div>
    <script>
        var divs = document.querySelectorAll('div');
        divs[0].onclick = function () {
            alert(221);
            this.onclick = null;
        }
        divs[1].addEventListener('click', fn);

        function fn() {
            alert(32);
            this.removeEventListener('click', fn)
        }
    </script>
</body>

</html>